## **Description**
The order book panel's open/closed state was local component state, so
it reset to closed on every mount — navigating between markets or
reloading the order entry page forced users who trade with the book open
to re-open it each time.
This persists the panel state through the perps controller's existing
`proLayoutPreferences`, alongside the already-persisted
`orderBookPosition`:
- Adds a `selectOrderBookExpanded` selector reading
`proLayoutPreferences?.orderBookExpanded`, falling back to
`DEFAULT_PRO_LAYOUT_PREFERENCES`.
- Seeds `isOrderBookOpen` in `perps-order-entry-page.tsx` from that
selector.
- Persists on toggle via `perpsSetProLayoutPreferences`. The write is
fire-and-forget — a failed preference save shouldn't block the UI toggle
— and logs on rejection.
The preference is flat rather than per-market, so the panel opens in the
same state on every symbol.
Also included: the order book config modal's layout pills had their
selected and unselected styles inverted, so the *unselected* option
appeared filled. Swaps `PILL_SELECTED_CLASS` / `PILL_UNSELECTED_CLASS`
so the selected pill is the filled
one (`bg-muted border-transparent`).
Note for reviewers: the diff in `perps-order-entry-page.tsx` includes
some incidental Prettier re-indentation of the existing TP/SL validation
block — no logic change there.
## **Changelog**
CHANGELOG entry: Added persistence for the perps order book panel, so it
stays open or closed between visits
## **Related issues**
Fixes: TAT-3737
## **Manual testing steps**
1. Enable perps and open the perps order entry page for any market (e.g.
BTC).
2. Toggle the order book panel **open**.
3. Navigate away (e.g. to another market or back to the wallet home) and
return to the order entry page — the order book should still be
**open**.
4. Reload the extension entirely and reopen the page — still **open**.
5. Toggle the panel **closed**, navigate away and back — it should stay
**closed**.
6. Switch to a different market and confirm the panel state carries over
(the preference is global, not per-market).
7. Open the order book settings modal and confirm the **currently
selected** layout pill is the filled one, and that changing the position
still works and persists.
## **Screenshots/Recordings**
### **Before**
<!-- [screenshots/recordings] -->
### **After**
Loom video showing persistence across markets:
https://www.loom.com/share/ead2698863c34b7fa27d7937eb6cafe3
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> UI layout preference persistence and a cosmetic pill-style fix; no
auth, payments, or trading logic changes.
>
> **Overview**
> **Persists the order book panel** so open/closed no longer resets on
every visit. The order entry page seeds `isOrderBookOpen` from a new
`selectOrderBookExpanded` selector
(`proLayoutPreferences.orderBookExpanded`, default closed) and writes
the value on toggle through `perpsSetProLayoutPreferences`
(fire-and-forget with error logging). The preference is global across
markets, matching existing layout prefs like `orderBookPosition`.
>
> **Fixes order book config modal pills** by swapping
`PILL_SELECTED_CLASS` / `PILL_UNSELECTED_CLASS` so the selected layout
option shows as filled (`bg-muted`) instead of the unselected one.
>
> Tests cover selector defaults, mounting with persisted expanded state,
and persistence calls on toggle.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
05bc898. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Description
The order book panel's open/closed state was local component state, so it reset to closed on every mount — navigating between markets or reloading the order entry page forced users who trade with the book open to re-open it each time.
This persists the panel state through the perps controller's existing
proLayoutPreferences, alongside the already-persistedorderBookPosition:selectOrderBookExpandedselector readingproLayoutPreferences?.orderBookExpanded, falling back toDEFAULT_PRO_LAYOUT_PREFERENCES.isOrderBookOpeninperps-order-entry-page.tsxfrom that selector.perpsSetProLayoutPreferences. The write is fire-and-forget — a failed preference save shouldn't block the UI toggle — and logs on rejection.The preference is flat rather than per-market, so the panel opens in the same state on every symbol.
Also included: the order book config modal's layout pills had their selected and unselected styles inverted, so the unselected option appeared filled. Swaps
PILL_SELECTED_CLASS/PILL_UNSELECTED_CLASSso the selected pill is the filledone (
bg-muted border-transparent).Note for reviewers: the diff in
perps-order-entry-page.tsxincludes some incidental Prettier re-indentation of the existing TP/SL validation block — no logic change there.Changelog
CHANGELOG entry: Added persistence for the perps order book panel, so it stays open or closed between visits
Related issues
Fixes: TAT-3737
Manual testing steps
Screenshots/Recordings
Before
After
Loom video showing persistence across markets:
https://www.loom.com/share/ead2698863c34b7fa27d7937eb6cafe3
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
UI layout preference persistence and a cosmetic pill-style fix; no auth, payments, or trading logic changes.
Overview
Persists the order book panel so open/closed no longer resets on every visit. The order entry page seeds
isOrderBookOpenfrom a newselectOrderBookExpandedselector (proLayoutPreferences.orderBookExpanded, default closed) and writes the value on toggle throughperpsSetProLayoutPreferences(fire-and-forget with error logging). The preference is global across markets, matching existing layout prefs likeorderBookPosition.Fixes order book config modal pills by swapping
PILL_SELECTED_CLASS/PILL_UNSELECTED_CLASSso the selected layout option shows as filled (bg-muted) instead of the unselected one.Tests cover selector defaults, mounting with persisted expanded state, and persistence calls on toggle.
Reviewed by Cursor Bugbot for commit 05bc898. Bugbot is set up for automated code reviews on this repo. Configure here.